﻿using System.Collections.Generic;

namespace Chevron.OrderDetails.Models
{
    public class LabTestDto
    {
        public string TestCode { get; set; }
        public string TestName { get; set; }
        public decimal Price { get; set; }
        public TestCategory Category { get; set; }

        public static LabTestDto Deserialize(string line, TestCategoryCatalog catalog)
        {
            List<string> fields = Utilities.AlaSplitFields(line);
            var testobj = new LabTestDto
                              {
                                  TestCode = fields[(int) AlaColumns.IntTestId],
                                  TestName = fields[(int) AlaColumns.Name],
                                  Category = catalog[fields[(int) AlaColumns.Lab].Trim()],
                                  Price = fields[(int) AlaColumns.ListPrice].ToDecimal()
                              };
            return testobj;
        }

        #region Nested type: AlaColumns

        private enum AlaColumns
        {
            ItemType = 0,
            IntTestId,
            ExtTestId,
            Name,
            ActiveDate,
            InactiveDate,
            NotOrderable = 7,
            Lab,
            AccessionType = 10,
            IsProfile = 12,
            ProfilePrintingType,
            Mnemonics = 18,
            ResultCodes = 20,
            ListPrice,
            IsBillable = 25,
            AutoSelectProfileComponents,
            ProfileComponents = 37,
            AllComponentsReturnForProfile = 49
        }

        #endregion
    }
}